package dmir.reaction.publico.graph.neo4j;

import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.kernel.EmbeddedGraphDatabase;
import org.neo4j.tooling.GlobalGraphOperations;

public class LoadExportedGraph {
	
	public static void main(String[] args) {
		
		GraphDatabaseService graphDb = new EmbeddedGraphDatabase(args[1]);
		 GlobalGraphOperations operations = GlobalGraphOperations.at(graphDb);
		 
		 int nodes=0;
		 for (Node n : operations.getAllNodes()) {
			nodes++;
		}
		 
		int edges=0; 
		for (Relationship r : operations.getAllRelationships()) {
			 edges++;
		}
		
		System.out.println("nodes: " + nodes);
		System.out.println("edes:  " + edges);
		
		graphDb.shutdown();
	}
	
	private static void registerShutdownHook( final GraphDatabaseService graphDb )
	{
	    // Registers a shutdown hook for the Neo4j instance so that it
	    // shuts down nicely when the VM exits (even if you "Ctrl-C" the
	    // running example before it's completed)
	    Runtime.getRuntime().addShutdownHook( new Thread()
	    {
	        @Override
	        public void run()
	        {
	            graphDb.shutdown();
	        }
	    } );
	}
}
